package com.bckj.fastboot.paid.biz.infrastructure.producer;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.bean.ProducerBean;
import com.bckj.fastboot.core.jackson.JsonUtils;
import com.bckj.fastboot.mq.ons.AbstractOnsProducer;
import com.bckj.fastboot.paid.api.constant.PayMQConstants;
import com.bckj.fastboot.paid.api.model.PayResultMsg;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

//@Component
@RequiredArgsConstructor
public class PayResultMsgProducer extends AbstractOnsProducer<PayResultMsg> {

    private final ProducerBean producer;

    @Override
    public void sendMessage(PayResultMsg params) {
        var message = new Message(PayMQConstants.PAY_TOPIC, PayMQConstants.PAY_TAG_RESULT, JsonUtils.toJsonStr(params).getBytes());
        producer.sendAsync(message, new SimpleSendCallback(params));
    }
}
